#ifndef STRUCT_ESSENTIALS_H
#define	STRUCT_ESSENTIALS_H 
#ifdef __cplusplus
  extern "C" {
  #endif
#include "RBtree.h"

typedef struct _list list;

struct _list {
	/* K: Consider using this:
	struct _list* search (void* data, int* cmp(...), enum ListType list).
	Then you are writing 3 cmp functions (or more), returning 1 on sucsessful find
		and use search(id, func, by_type);
		This can be wrapped.
		Same with remove...().
	enum ListType{...}*/
	list *tprev;
	list *mprev;
	list *sprev;
	size_t id;
        off_t offset;
        size_t size;
        void* ptr;
        size_t refcnt;
	list *tnext;
	list *mnext;
	list *snext;
        leaf *node;
};
extern list *delim;
extern size_t MEM, MEM_USED;
extern off_t SWAP, SWAP_USED, TOTAL, TOTAL_USED;


void* DataInit(size_t mem, off_t swap, size_t total);
void DataDeinit();
/*if 0 or (data_p)0 - something went wrong and writes errno*/
list* findListById(size_t id);
list* addData(size_t id, size_t size);

void reset();
void removeFromSRing(list* removeMe);
void removeFromMRing(list* removeMe);
void removeFromTRing(list* removeMe);

#ifdef __cplusplus
  }
  #endif
#endif	/* STRUCT_ESSENTIALS_H */